
#include "CShopConfig.h"

int CMysticalShopItemDrop::AddDropData(unsigned char ucShopId, unsigned char ucPos, unsigned char ucDropType, int iDropRate)
{
    CRateTarget stDrop;
    stDrop._iTargetID = ucPos;
    stDrop._iMaxCount = CRateTarget::TARGET_INFINITY;
    stDrop._iRate = iDropRate;

    if ((MYSTICAL_UPDATE_GOLD != ucDropType)
        && (MYSTICAL_UPDATE_CANE != ucDropType))
    {
        return -1;
    }

    if (MYSTICAL_UPDATE_CANE == ucDropType)
    {
        _astNormDrop[ucShopId].Add(stDrop);
    }
    else
    {
        _astGoldDrop[ucShopId].Add(stDrop);
    }

    return 0;
}

int CMysticalShopItemDrop::DropShopItem(unsigned char ucShopId, unsigned char ucDropType, unsigned char &ucPos)
{    
    int iRet;
    CRateTarget stDrop;
    if (MYSTICAL_UPDATE_CANE == ucDropType)
    {
        iRet = _astNormDrop[ucShopId].DropOne(stDrop);
    }
    else
    {
        iRet = _astGoldDrop[ucShopId].DropOne(stDrop);
    }
    CHECK_RETURN(iRet);

    ucPos = (unsigned char)(stDrop._iTargetID & 0x7F);
    return 0;
}


int CClanShopItemDrop::AddDropData(unsigned char ucShopId, unsigned char ucPos, int iDropRate)
{
    CRateTarget stDrop;
    stDrop._iTargetID = ucPos;
    stDrop._iMaxCount = CRateTarget::TARGET_INFINITY;
    stDrop._iRate = iDropRate;
    
    _astDrop[ucShopId].Add(stDrop);

    return 0;
}

int CClanShopItemDrop::DropShopItem(unsigned char ucShopId, unsigned char &ucPos)
{    
    int iRet;
    CRateTarget stDrop;
    
    iRet = _astDrop[ucShopId].DropOne(stDrop);
    CHECK_RETURN(iRet);

    ucPos = (unsigned char)(stDrop._iTargetID & 0x7F);
    return 0;
}
